/*!
 * \file merge_symbol_table_visitor.h
 *
 * \brief Declarations of the merge_symbol_table_visitor that traverses the
 *        Symbol Table's symbols
 *
 * \date Started: 9/13/2010
 * \date Last Modified: 9/13/2010
 * \authors Ian Craig
 *
 * Copyright (c) 2010, Colorado State University <br>
 * All rights reserved. <br>
 * See ../../COPYING for details. <br>
 */

#include <iegenlib/iegenlib.h>

#include <string>
#include <list>
#include <set>
#include <utility>

namespace iegenlib{

class MergeSymbolTableVisitor: public SRVisitor{
public:

  inline MergeSymbolTableVisitor(SymbolTable* oldSym, SymbolTable* newSym, map<string, string>* map, list<TupleType> tups):
        oldST(oldSym), newST(newSym), mapping(map), newTups(tups), currExpVec(NULL){}

  virtual ~MergeSymbolTableVisitor();

  void ExpVecIn(const ExpVec* vec);

  void UFCallCase(UFCall* ufcall);

  void SREqualityOut(const SREquality* eq);

  void SRInequalityOut(const SRInequality* eq);

  void SRConjunctionOut(const SRConjunction* SRConj);

  inline SRConjunction getNewConjunction(){ return *(conjunctions.begin()); }

  inline void defaultIn(){}
  inline void defaultOut(){}

  int is_tupleVar(ExpVec vec, int i);

private:
  SymbolTable *oldST, *newST;
  map<string, string>* mapping;
  list<TupleType> newTups;
  ExpVec* currExpVec;
  set<SREquality> equals;
  set<SRInequality> inequals;
  set<SRConjunction> conjunctions;
};

}//end namespace iegenlib
